package com.neo.interview.study.thread;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.atomic.AtomicReference;

/**
 * @ClassName: CASDemo
 * @Title: demo
 * @Package: com.neo.interview.study.thread
 * @Description: 1. CAS是什么？ ===> compareAndSet
 * 比较并交换
 * @Author: Kisen
 * @Date: 2021/8/8 1:40
 */
public class CASDemo {
    public static void main(String[] args) {
        AtomicInteger atomicInteger = new AtomicInteger(5);
        // main do thing....
        System.out.println(atomicInteger.compareAndSet(5, 2021) + "\t current data：" + atomicInteger.get());
        System.out.println(atomicInteger.compareAndSet(5, 1024) + "\t current data：" + atomicInteger.get());
    }
}
